package com.example.demo.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.mapper.BrandMapper;
import com.example.demo.pojo.TbBrand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BrandService {

    @Autowired
    private BrandMapper brandMapper;

    public List<TbBrand> findAll(){
        return brandMapper.selectList(null);
    }

    public IPage<TbBrand> findPageByFirstChar(long pageNum,long pageSize,String firstChar){
        IPage<TbBrand> page = brandMapper.selectPage(new Page<TbBrand>(pageNum, pageSize),
                new QueryWrapper<TbBrand>()
                        .eq("first_char", firstChar));
        System.out.println(page.getRecords());
        System.out.println("总条数："+page.getTotal());
        return page;
    }
}
